import { reactive } from "vue"

interface userInfo{
    avatarUrl:string,
    city:string,
    gender:number,
    language:string,
    nickName:string,
    province:string
}

export let myUserInfo = reactive({
    avatarUrl:'' as string,
    city:'' as string,
    gender:0 as number,
    language:'' as string,
    nickName:'' as string,
    province:'' as string
})


export function getUser(){
    uni.getUserProfile({
        desc:'获取用户信息',
        success:(response)=>{
            console.log(response)
            myUserInfo.avatarUrl = response.userInfo.avatarUrl
            myUserInfo.nickName = response.userInfo.nickName
            console.log(myUserInfo)
        },
        fail:(err)=>{
            console.log(err)
        },
        complete:()=>{
            uni.redirectTo({
                url: `../index/index?myUserInfo=${myUserInfo}`
            })
        }
    })
}